package com.lyl.domaindemo.Infrastructure.exceptionhandler;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;

/**
 * @author lyl
 * @date 2023/5/19
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class GlobalExceptionResponse {

    private Mata mata;

    private Data data;

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    static class Mata {
        private HttpMethod method;

        private String manner;

        public Mata(HttpRequest request){
            this.method = request.getMethod();
            this.manner = request.getMethodValue();
        }
    }

    @Setter
    @Getter
    @NoArgsConstructor
    @AllArgsConstructor
    static class Data {
        private String code;

        private String message;
    }
}
